<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%> 
 
<div style="margin:20px 0;"></div>
<div class="easyui-panel" >
	<div style="padding:10px 60px 20px 60px">
    <form id="channelinfForm"  name="channelinfForm" method="post" >
    	<input type="hidden" name="channel_uuid" value="${infChannel.channel_uuid}"/>
    	<table cellpadding="5" style="width:100%">
    		<tr>
    			<td>通道编号:</td>
    			<td><input class="easyui-textbox" type="text" name="channel_no" data-options="required:true,validType:['checkchnno']" value="${infChannel.channel_no }"></input></td>    	     			
    		</tr>
    		<tr>
    			<td>通道名称:</td>
    			<td><input class="easyui-textbox" type="text" name="chn_nm" data-options="required:true,validType:['length[0,20]']" value="${infChannel.chn_nm }"></input></td>    	     			
    		</tr>
    		<tr>
    			<td>通道类型:</td>
    			<td><code:codeSelect id="chn_tp" name="chn_tp" code_type="chn_tp" showSelect="false" selectId="${infChannel.chn_tp}"></code:codeSelect></td>    	     			
    		</tr>
    		<tr>
    			<td>通道对应表:</td>
    			<td><input class="easyui-textbox" type="text" name="chn_prmtb" data-options="required:true,validType:['checkchnprmtb']" value="${infChannel.chn_prmtb }"></input></td>    	     			
    		</tr>
    		<tr>
    			<td>交易频率(秒):</td>
    			<td><input class="easyui-textbox" type="text" name="trans_interval" data-options="required:true,validType:['checkNum']" value="${infChannel.trans_interval }"></input></td>    	     			
    		</tr>     		 		  		    		 
    		<tr>
    			<td>切换商户时间(分钟):</td>
    			<td><input class="easyui-textbox" type="text" name="change_mchnt_tm" data-options="required:true,validType:['checkNum']" value="${infChannel.change_mchnt_tm }"></input></td>    	     			
    		</tr>
    	</table>
    
	    <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-save" id="saveBtn">保存</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-back" onclick="back()">返回</a>
	    </div>
    </form>
    </div>
</div>
<script>
$(document).ready(function() {
	$.extend($.fn.textbox.defaults.rules, {
		checkchnno: {     
            validator: function(value){               
                 var reg = new RegExp("^[a-zA-Z0-9_]{0,30}$"); 
                 return reg.test(value);  
            },     
            message: '通道编号只能包含数字字母和“_”，长度0-30'     
        },        
        checkchnprmtb: {     
            validator: function(value){               
                 var reg = new RegExp("^[a-zA-Z0-9_]{0,30}$"); 
                 return reg.test(value);  
            },     
            message: '通道对应表只能包含数字字母和“_”，长度0-30'     
        },
		checkNum: {     
            validator: function(value){               
                 var reg = new RegExp("^[0-9]{0,4}$"); 
                 return reg.test(value);  
            },     
            message: '交易频率需为0-4位的数字'     
        }        
	});
	
	$("#saveBtn").click(function(){	
		if($("#channelinfForm").form("validate")){			
			var options ={   
		            url:'<c:url value="/channelinf/checkChannelInf.do"/>',   
		            type:'post',                    
		            success:function(data){		            	  
						  if("success"==data){					  
							  //表单提交的方法、比如ajax提交
					    	  $("#channelinfForm").attr("action","../channelinf/saveChannelInf.do?");
					    	  document.getElementById("channelinfForm").submit();  						  
						  }else if("f2"==data){
							  $.jpmessage.info('通道编号不能重复!');
						  }else if("f1"==data){
							  $.jpmessage.info('通道对应表不存在!');
						  }
		            }   
		         };
			$("#channelinfForm").ajaxSubmit(options); 
		}
		
	});
	$("body").keydown(function() {
        if (event.keyCode == "13") {//keyCode=13是回车键
            $('#saveBtn').click();
        }
    });
})
</script>